import { readFileSync } from 'fs';
import path from 'path';

import yaml from 'js-yaml';

import type { SystemConfig } from './types';

// 读取配置文件
let config: SystemConfig;

// 根据不同环境加载不同的配置文件
if (process.env.NODE_ENV === 'development') {
  config = yaml.load(readFileSync(path.join('env/env.dev.yaml'), 'utf8')) as SystemConfig;
} else {
  config = yaml.load(readFileSync(path.join('env/env.prod.yaml'), 'utf8')) as SystemConfig;
}

export const { SERVER, DATABASE, JSON_WEB_TOKEN, SWAGGER, CAPTCHA, WX_MINI, EMAIL } = config;
